package com.huishi.enums;

/**
 * DataX插件
 */
public enum DataXPlugin {
    MYSQL("mysqlreader", "mysqlwriter", "mysql"),
    ORACLE("oraclereader", "oraclewriter", "oracle");

    private final String reader;
    private final String writer;
    private final String type;

    DataXPlugin(String reader, String writer, String type) {
        this.reader = reader;
        this.writer = writer;
        this.type = type;
    }

    public String getReader() {
        return reader;
    }

    public String getWriter() {
        return writer;
    }

    public String getType() {
        return type;
    }


    public static String getReader(String type) {
        for (DataXPlugin plugin : DataXPlugin.values()) {
            if (plugin.getType().equals(type)) return plugin.getReader();
        }
        return null;
    }

    public static String getWriter(String type) {
        for (DataXPlugin plugin : DataXPlugin.values()) {
            if (plugin.getType().equals(type)) return plugin.getWriter();
        }
        return null;
    }
}
